/**
 * Created by asus on 2017/5/5.
 */
const faker = require('faker')
const lib = require('lodash')
faker.locale = 'zh_CN'

module.exports = {
  api: '/codi-admin-mock/course/list',
  response: function (req, res) {
    console.log(req.query)
    let index = parseInt(req.query.page)
    let size = parseInt(req.query.size)
    let title = req.query.title
    const total = 25
    const page = Math.ceil(total / size)
    let resNum = index >= page ? (total - (index - 1) * size) : size
    let content = '什么是基金'
    if (title) {
      content = `搜索的标题:${title}`
    }
    let data = {
      'success': true,
      'objs': lib.times(resNum, function (n) {
        return {
          'courseContent': '基金是稳定投资',
          'courseId': n + ((index - 1) * size),
          'courseTitle': content + (n + ((index - 1) * size)),
          'courseType': n % 3,
          'modifyDate': 1493778376087,
          'publishDate': 1493883078000,
          'publisher': '张三'
        }
      }),
      'page': index,
      'rowCount': resNum,
      'size': resNum,
      'totalNum': total,
      'totalPage': page
    }
    res.json(data)
  }
}
